<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>vue指令小项目2</title>
    <script src="node_modules/vue/dist/vue.js"></script>
    <link rel="stylesheet" href="./css/index.css" />

</head>
<body>

<div id="mask">
    <div class="center">
        <a href="javascript:void(0)" @click="sub" class="right">
            <img src="./img/next.png" alt="" />
        </a>
        <img :src="imgarr[cout]" alt="" />
        <a href="javascript:void(0)" @click="add" class="left">
            <img src="./img/prev.png" alt="" />
        </a>
        <!--<h2 v-text="cout"></h2>-->
    </div>
</div>

<script>
    var mask = new Vue({
        el:"#mask",
        data:{
            imgarr:[
                "./img/00.jpg",
                "./img/01.jpg",
                "./img/03.jpg",
                "./img/04.jpg",
                "./img/05.jpg",
                "./img/06.jpg",
                "./img/07.jpg",
                "./img/08.jpg",
                "./img/09.jpg",
                "./img/10.jpg",
            ],
            cout:0
        },
        methods: {
            add: function () {
                this.cout++;
                if(this.cout>9){
                    alert("以及达到最大值");
                }
            },
            sub: function () {
                this.cout--;
                if(this.cout<0){
                    alert("以及达到最小值");
                    this.cout = 0 ;
                }
            }
        }
    })
</script>

</body>
</html>